﻿class GlobalAudio {
    public static play1(url: string, callback?: Function): void {

        this.stop1();

        this.audio = new Audio();
        //snd.src = url;



        //var audio = <HTMLAudioElement>document.getElementById("audio");
        //this.audio.pause();
        this.audio.src = url;
        this.audio.onended = function() {
            //alert("播放完成");
            if (callback != null)
                callback();
        }
        this.audio.play();
    }

    private static audio;

    public static stop1(): void{

        //var audio = <HTMLAudioElement>document.getElementById("audio");
        if (this.audio) {
            this.audio.onended = null;
            this.audio.pause();
            this.audio.src = "";
        }
        this.audio = null;
    }
} 